<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目-选取项目')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>负责人 ：</label>
                            <input type="text" name="contactPerson"/>
                        </li>
                        <li>
                            <label>项目名称 ：</label>
                            <input type="text" name="projectName"/>
                        </li>
                        <li>
                            <label>联系电话 ：</label>
                            <input type="text" name="tel"/>
                        </li>
                        <li>
                            <label>邮箱 ：</label>
                            <input type="text" name="email"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "system/project";
    $(function() {
        var options = {
            url: prefix + "/projectList",
            modalName: "商品信息",
            columns: [{
                radio: true
            },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'contactPerson',
                    title: '负责人 '
                },
                {
                    field: 'tel',
                    title: '联系电话 '
                },
                {
                    field: 'email',
                    title: '邮箱 '
                },
                {
                    field: 'remark',
                    title: '备注 '
                }
                ]
        };
        $.table.init(options);
    });


    function doSelect(){

        table.set();
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }

        return rows[0];
    }

    function addData(){
        // $.modal.closeTab();

        $.operate.selectProduct("/system/project/projectListPage",selectProductCallback);

        // $("#" + table.options.id).bootstrapTable('append',newRow);

    }

    function selectProductCallback(productId) {

        console.log("selectProductCallback"+productId);

        var config = {
            url: ctx+"scm/product/detail/"+productId,
            type: "post",
            dataType: "json",
            data: null,
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍候...");
            },
            success: function(result) {

                console.log(result);
                console.log(result.data);

                addProduct(result.data);
                $.modal.closeLoading();
            }
        };
        $.ajax(config);

    }

    function onEditableSave (field, row, rowIndex, oldValue, $el) {

        // alert("字段名：" + field + "，当前值：" + row[field]  + "，旧值：" + oldValue);

    }



</script>
</body>
</html>
